//
//  FirstOtherTableViewCell.m
//  Project_B
//
//  Created by 张闯的mac pro on 15/11/23.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "FirstOtherTableViewCell.h"
#import "FirstModel.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface FirstOtherTableViewCell ()

@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UILabel *name;
@property (nonatomic, strong) UIView *background;


@end

@implementation FirstOtherTableViewCell

#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.image = [[UIImageView alloc] init];
        [self.contentView addSubview:self.image];
        self.image.userInteractionEnabled = YES;
        
        self.background = [[UIView alloc] init];
        [self.image addSubview:self.background];
        
        self.name = [[UILabel alloc] init];
        [self.image addSubview:self.name];
    }
    return self;
}
#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
    
    self.background.backgroundColor = [UIColor blackColor];
    self.background.alpha = 0.5;
    self.background.frame = CGRectMake((WIDTH - 250) / 2, (self.image.frame.size.height - 20) / 2, 250, 30);
    
    self.name.textColor = [UIColor whiteColor];
    self.name.font = [UIFont systemFontOfSize:20];
    self.name.textAlignment = NSTextAlignmentCenter;
    self.name.frame = CGRectMake(self.background.frame.origin.x + 15, self.background.frame.origin.y + 5, self.background.frame.size.width - 30, self.background.frame.size.height - 10);
}
#pragma mark - 赋值
- (void)setOtherFirstModel:(FirstModel *)otherFirstModel
{
    if (_otherFirstModel != otherFirstModel) {
        _otherFirstModel = otherFirstModel;
    }
    self.name.text = otherFirstModel.name;
    [self.image sd_setImageWithURL:[NSURL URLWithString:otherFirstModel.images] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
